package com.bright.tactiviti.process.task;


import org.activiti.engine.TaskService;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * 组内任务
 */
@SpringBootTest
public class GroupTaskNote {
    //注入TaskService
    @Autowired
    private TaskService taskService;


    /**
     * 查询办理人
     * 操作对应的表
     * ACT_RU_TASK
     */
    @Test
    public void taskQueryByAssignee(){
        String assignee = "userA";

        List<Task> tasks = taskService.createTaskQuery()
                .list();
        tasks.forEach(task -> {
            System.out.println("任务办理人:" + task.getAssignee());
        });
    }
    /**
     * 查询组内成员
     * 操作的数据表
     * ACT_RU_IDENTITYLINK
     */
    @Test
    public void groupTaskQueryByTaskId(){
        String taskId = "17505";
        List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
        identityLinks.forEach(identity -> {
            System.out.println("用户ID:  " + identity.getUserId());
            System.out.println("任务ID:  " + identity.getTaskId());
            System.out.println("任务实例ID:  " + identity.getProcessInstanceId());
            System.out.println("任务类型:  " + identity.getType());
            System.out.println("= = = = = = = = = = = = = = = = = = = = = = = =");
        });
    }
}

